package com.zhkj.shixi.tvplayer.VideoPlayer;

import android.app.Activity;
import android.util.Log;

import com.zhkj.shixi.tvplayer.Interface.PlayOrder;

import java.io.File;
import java.util.List;
import java.util.Random;

import static android.content.ContentValues.TAG;

/**
 * Created by chenhao on 19-8-13.
 */

public class VideoPlayOrder implements PlayOrder {
    private Activity mActivity;
    public static final int ORDER = 0;   //顺序
    public static final int CYCLE = 1; //列表循环
    public static final int SINGLE = 2; //当前循环
    public static final int RAND = 3; //随机
    private int position;
    private int type = ORDER;//顺序播放：0,播放列表循环：1,当前文件循环：2,随即播放：3


    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public void setType(int type) {
        Log.i(TAG, "setType: ------------------------" + type);
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public VideoPlayOrder(Activity activity) {
        mActivity = activity;

    }

    /**
     * @param files
     */
    @Override
    public void setOrderType(List<File> files) {

        switch (type) {
            case ORDER:
                break;
            case CYCLE:
                if (position == files.size() - 1) {
                    position = 0;
                } else
                    position++;
                break;
            case SINGLE:
                break;
            case RAND:
                Random random = new Random();
                //产生随机数
                position = random.nextInt(files.size());
                break;
            default:
                break;

        }

    }
}

